﻿@using DLULearningNetwork.ViewModels;
@{
    List<LeftMainMenuItem> Menus = LeftMainMenuItem.CreateMenu();
    List<string> activeMenus = ViewBag.ActiveMenus;
    if (ViewBag.ActiveMenus == null)
    {
        activeMenus = new List<string>();
    }
}
<div class="VerticalMenu">
    <ul>
        @foreach (LeftMainMenuItem item in Menus)
        {
            if (activeMenus.Contains(item.Name))
            {
            <li class="active"><a href="@item.Href">@item.DisplayedName</a>
                @if (item.SubMenu != null)
                {
                    <div class="SubMenu" style="display:block;">
                        <ul>
                            @foreach (LeftMainMenuItem subi in item.SubMenu)
                            {
                                if (activeMenus.Contains(subi.Name))
                                {
                                <li class="active"><a href="@subi.Href">@subi.DisplayedName</a></li>
                                }
                                else
                                {
                                <li><a href="@subi.Href">@subi.DisplayedName</a></li>
                                }
                            }
                        </ul>
                    </div>
                }
            </li>
            }
            else
            {
            <li><a href="@item.Href">@item.DisplayedName</a>
                @if (item.SubMenu != null)
                {
                    <div class="SubMenu" style="display:none;">
                        <ul>
                            @foreach (LeftMainMenuItem subi in item.SubMenu)
                            {
                                <li><a href="@subi.Href">@subi.DisplayedName</a></li>
                            }
                        </ul>
                    </div>
                }
            </li>
            }
        }
    </ul>
</div>
